package cn.xumaoyang.user.controller;

import cn.xumaoyang.basic.exception.BusinessException;
import cn.xumaoyang.basic.util.AjaxResult;
import cn.xumaoyang.user.dto.Userdto;
import cn.xumaoyang.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 前端注册controller、
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/register")
    public AjaxResult registouser(@RequestBody Userdto userdto){
        try {
            //转给service进行下一步操作。
            userService.loadByPhone(userdto);
            return new AjaxResult();
        }catch (BusinessException e) {
            e.printStackTrace();
            return new AjaxResult(false,e.getMessage());
        }
        catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult(false,"系统繁忙");
        }
    }

}
